# -*- coding=utf8 -*-
import threading
import logging
from pospal import member_spider as pospal
from youzan import member_spider as youzan


logging.basicConfig(level=logging.DEBUG,
                format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
                datefmt='%Y-%m-%d %H:%M:%S',
                filename='pospal.log',
                filemode='w')

def youzan_login():
    login_result = youzan.login()
    while login_result is False:
        print("error login failed, relogin")
        login_result = youzan_login()

if __name__=='__main__':
     youzan_login()
     pospal.login()

     pospal.sync_members(loop=True)
     youzan.sync_members(loop=True)

     pospal.keep_session(loop=True)
     youzan.keep_session(loop=True)
